import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
import storage_clear from '@feidao/web/atom/browser/storage/clear';
import user_logout from '@feidao/web/atom/browser/msg/user-logout';
import set_user from '@feidao/web/atom/browser/storage/put';
import { send_msg as url, systemid, get_user_info } from './config';
import whoami from '@feidao/web/atom/browser/msg/whoami';
export default async function (fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	const user = await whoami(get_user_info) as {
		usercode: string
	};
	const user_info = <{ code: number }>await user_logout(url, systemid, user.usercode);
	if (user_info.code == 1) {
		await set_user('user', null)
		await storage_clear('user');
		await storage_clear();
		window.location.href = 'login.html';
	}

}
